
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>开发package · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-toggle-chapters/toggle.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="platform-channel.html" />
    
    
    <link rel="prev" href="./" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 30px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .ad {
            color: white;
            text-align: center;
            background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);
            background-size: cover;
            cursor: pointer;
            margin-bottom: 30px;
            padding: 18px
        }

        .ad:hover {
            opacity: .8;
        }
    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
    <!--<div class="ad ad0"-->
         <!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
        <!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
        <!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
    <!--</div>-->
    <!--<div class="ad ad1"-->
         <!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
        <!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
        <!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
    <!--</div>-->
<!--</div>-->

<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    缘起
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    Flutter简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../chapter1/configuration.html">
            
                <a href="../chapter1/configuration.html">
            
                    
                    常见配置问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter2/">
            
                <a href="../chapter2/">
            
                    
                    第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter2/first_flutter_app.html">
            
                <a href="../chapter2/first_flutter_app.html">
            
                    
                    计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter2/flutter_router.html">
            
                <a href="../chapter2/flutter_router.html">
            
                    
                    路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter2/flutter_package_mgr.html">
            
                <a href="../chapter2/flutter_package_mgr.html">
            
                    
                    包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter2/flutter_assets_mgr.html">
            
                <a href="../chapter2/flutter_assets_mgr.html">
            
                    
                    资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter2/flutter_app_debug.html">
            
                <a href="../chapter2/flutter_app_debug.html">
            
                    
                    调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../chapter2/thread_model_and_error_report.html">
            
                <a href="../chapter2/thread_model_and_error_report.html">
            
                    
                    Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    基础Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    输入框和表单
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    布局类Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter4/intro.html">
            
                <a href="../chapter4/intro.html">
            
                    
                    布局类Widgets简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter4/row_and_column.html">
            
                <a href="../chapter4/row_and_column.html">
            
                    
                    线性布局Row、Column
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter4/flex.html">
            
                <a href="../chapter4/flex.html">
            
                    
                    弹性布局Flex
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter4/wrap_and_flow.html">
            
                <a href="../chapter4/wrap_and_flow.html">
            
                    
                    流式布局Wrap、Flow
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter4/stack.html">
            
                <a href="../chapter4/stack.html">
            
                    
                    层叠布局Stack、Positioned
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    容器类Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    Padding
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    布局限制类容器ConstrainedBox、SizeBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    装饰容器DecoratedBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    变换Transform
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    可滚动Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    可滚动Widgets简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    滚动监听及控制ScrollController
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    功能型Widgets
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter7/willpopscope.html">
            
                <a href="../chapter7/willpopscope.html">
            
                    
                    导航返回拦截-WillPopScope
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter7/inherited_widget.html">
            
                <a href="../chapter7/inherited_widget.html">
            
                    
                    数据共享-InheritedWidget
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter7/theme.html">
            
                <a href="../chapter7/theme.html">
            
                    
                    主题-Theme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    通知Notification
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    交错动画
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    自定义Widget
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter13/intro.html">
            
                <a href="../chapter13/intro.html">
            
                    
                    自定义Widget方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter13/combine.html">
            
                <a href="../chapter13/combine.html">
            
                    
                    通过组合现有Widget实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter13/turn_box.html">
            
                <a href="../chapter13/turn_box.html">
            
                    
                    实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter13/custom_paint.html">
            
                <a href="../chapter13/custom_paint.html">
            
                    
                    CustomPaint与Canvas
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter13/gradient_circular_progress_demo.html">
            
                <a href="../chapter13/gradient_circular_progress_demo.html">
            
                    
                    实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter10/file_operation.html">
            
                <a href="../chapter10/file_operation.html">
            
                    
                    文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter10/http.html">
            
                <a href="../chapter10/http.html">
            
                    
                    Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter10/dio.html">
            
                <a href="../chapter10/dio.html">
            
                    
                    Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter10/download_with_chunks.html">
            
                <a href="../chapter10/download_with_chunks.html">
            
                    
                    实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter10/websocket.html">
            
                <a href="../chapter10/websocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter10/socket.html">
            
                <a href="../chapter10/socket.html">
            
                    
                    使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../chapter10/json_model.html">
            
                <a href="../chapter10/json_model.html">
            
                    
                    Json转Model
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="./">
            
                <a href="./">
            
                    
                    包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.13.1" data-path="develop_package.html">
            
                <a href="develop_package.html">
            
                    
                    开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="platform-channel.html">
            
                <a href="platform-channel.html">
            
                    
                    插件开发：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="android_implement.html">
            
                <a href="android_implement.html">
            
                    
                    插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="ios_implement.html">
            
                <a href="ios_implement.html">
            
                    
                    插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../todo.html">
            
                <a href="../todo.html">
            
                    
                    系统能力调用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../chapter12/">
            
                <a href="../chapter12/">
            
                    
                    国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../chapter12/multi_languages_support.html">
            
                <a href="../chapter12/multi_languages_support.html">
            
                    
                    让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter12/locallization_implement.html">
            
                <a href="../chapter12/locallization_implement.html">
            
                    
                    实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter12/intl.html">
            
                <a href="../chapter12/intl.html">
            
                    
                    使用Intl包
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter14/flutter_ui_system.html">
            
                <a href="../chapter14/flutter_ui_system.html">
            
                    
                    Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter14/element_buildcontext.html">
            
                <a href="../chapter14/element_buildcontext.html">
            
                    
                    Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter14/render_object.html">
            
                <a href="../chapter14/render_object.html">
            
                    
                    RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../chapter14/flutter_app_startup.html">
            
                <a href="../chapter14/flutter_app_startup.html">
            
                    
                    Flutter从启动到显示
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../todo.html">
            
                <a href="../todo.html">
            
                    
                    Flutter资源汇总
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >开发package</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="package">Package</h1>
<p>&#x4F7F;&#x7528;package&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x5171;&#x4EAB;&#x7684;&#x6A21;&#x5757;&#x5316;&#x4EE3;&#x7801;&#x3002;&#x4E00;&#x4E2A;&#x6700;&#x5C0F;&#x7684;package&#x5305;&#x62EC;&#xFF1A;</p>
<ul>
<li>&#x4E00;&#x4E2A;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#xFF1A;&#x58F0;&#x660E;&#x4E86;package&#x7684;&#x540D;&#x79F0;&#x3001;&#x7248;&#x672C;&#x3001;&#x4F5C;&#x8005;&#x7B49;&#x7684;&#x5143;&#x6570;&#x636E;&#x6587;&#x4EF6;&#x3002;</li>
<li>&#x4E00;&#x4E2A; <code>lib</code> &#x6587;&#x4EF6;&#x5939;&#xFF1A;&#x5305;&#x62EC;&#x5305;&#x4E2D;&#x516C;&#x5F00;&#x7684;(public)&#x4EE3;&#x7801;&#xFF0C;&#x6700;&#x5C11;&#x5E94;&#x6709;&#x4E00;&#x4E2A;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>package-name</span><span class="token punctuation">&gt;</span></span>.dart</code>&#x6587;&#x4EF6;</li>
</ul>
<p>Flutter Packages&#x5206;&#x4E3A;&#x4E24;&#x7C7B;&#xFF1A;</p>
<ul>
<li>Dart&#x5305;&#xFF1A;&#x5176;&#x4E2D;&#x4E00;&#x4E9B;&#x53EF;&#x80FD;&#x5305;&#x542B;Flutter&#x7684;&#x7279;&#x5B9A;&#x529F;&#x80FD;&#xFF0C;&#x56E0;&#x6B64;&#x5BF9;Flutter&#x6846;&#x67B6;&#x5177;&#x6709;&#x4F9D;&#x8D56;&#x6027;&#xFF0C;&#x8FD9;&#x79CD;&#x5305;&#x4EC5;&#x7528;&#x4E8E;Flutter&#xFF0C;&#x4F8B;&#x5982;<a href="https://pub.dartlang.org/packages/fluro" target="_blank"><code>fluro</code></a>&#x5305;&#x3002;</li>
<li>&#x63D2;&#x4EF6;&#x5305;&#xFF1A;&#x4E00;&#x79CD;&#x4E13;&#x7528;&#x7684;Dart&#x5305;&#xFF0C;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x7528;Dart&#x4EE3;&#x7801;&#x7F16;&#x5199;&#x7684;API&#xFF0C;&#x4EE5;&#x53CA;&#x9488;&#x5BF9;Android&#xFF08;&#x4F7F;&#x7528;Java&#x6216;Kotlin&#xFF09;&#x548C;&#x9488;&#x5BF9;iOS&#xFF08;&#x4F7F;&#x7528;OC&#x6216;Swift&#xFF09;&#x5E73;&#x53F0;&#x7684;&#x7279;&#x5B9A;&#x5B9E;&#x73B0;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x63D2;&#x4EF6;&#x5305;&#x62EC;&#x539F;&#x751F;&#x4EE3;&#x7801;&#xFF0C;&#x4E00;&#x4E2A;&#x5177;&#x4F53;&#x7684;&#x4F8B;&#x5B50;&#x662F;<a href="https://pub.dartlang.org/packages/battery" target="_blank"><code>battery</code></a>&#x63D2;&#x4EF6;&#x5305;&#x3002;</li>
</ul>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x867D;&#x7136;Flutter&#x7684;Dart&#x8FD0;&#x884C;&#x65F6;&#x548C;Dart VM&#x8FD0;&#x884C;&#x65F6;&#x4E0D;&#x662F;&#x5B8C;&#x5168;&#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x662F;&#x5982;&#x679C;Package&#x4E2D;&#x6CA1;&#x6709;&#x6D89;&#x53CA;&#x8FD9;&#x4E9B;&#x5B58;&#x5728;&#x5DEE;&#x5F02;&#x7684;&#x90E8;&#x5206;&#xFF0C;&#x90A3;&#x4E48;&#x8FD9;&#x6837;&#x7684;&#x5305;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x652F;&#x6301;Flutter&#x548C;Dart VM&#xFF0C;&#x5982;Dart http&#x7F51;&#x7EDC;&#x5E93;<a href="https://github.com/flutterchina/dio" target="_blank">dio</a>. </p>
<h2 id="&#x5F00;&#x53D1;dart&#x5305;">&#x5F00;&#x53D1;Dart&#x5305;</h2>
<h3 id="&#x7B2C;&#x4E00;&#x6B65;&#xFF1A;&#x521B;&#x5EFA;dart&#x5305;">&#x7B2C;&#x4E00;&#x6B65;&#xFF1A;&#x521B;&#x5EFA;Dart&#x5305;</h3>
<p>&#x60A8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;Android Studio&#xFF1A;File&gt;New&gt;New Flutter Project &#x6765;&#x521B;&#x5EFA;&#xFF1A;</p>
<p><img src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/docs/imgs/image-20181204195346470.png" alt="image-20181204195346470"></p>
<p>&#x60A8;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4F7F;&#x7528;<code>--template=package</code> &#x6765;&#x6267;&#x884C; <code>flutter create</code> &#x547D;&#x4EE4;&#x6765;&#x521B;&#x5EFA;&#xFF1A;</p>
<pre class="language-"><code class="lang-shell">flutter create --template<span class="token operator">=</span>package hello
</code></pre>
<p>&#x8FD9;&#x5C06;&#x5728;<code>hello/</code>&#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5177;&#x6709;&#x4EE5;&#x4E0B;&#x4E13;&#x7528;&#x5185;&#x5BB9;&#x7684;package&#x5DE5;&#x7A0B;&#xFF1A;</p>
<ul>
<li><p><code>lib/hello.dart</code>&#xFF1A;Package&#x7684;Dart&#x4EE3;&#x7801;</p>
</li>
<li><p><code>test/hello_test.dart</code>&#xFF1A;Package&#x7684;&#x5355;&#x5143;&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;&#x3002;</p>
</li>
</ul>
<h3 id="&#x5B9E;&#x73B0;package">&#x5B9E;&#x73B0;package</h3>
<p>&#x5BF9;&#x4E8E;&#x7EAF;Dart&#x5305;&#xFF0C;&#x53EA;&#x9700;&#x5728;&#x4E3B;<code>lib/<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>package</span> <span class="token attr-name">name</span><span class="token punctuation">&gt;</span></span>.dart</code>&#x6587;&#x4EF6;&#x5185;&#x6216;<code>lib</code>&#x76EE;&#x5F55;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x529F;&#x80FD;&#x5373;&#x53EF; &#x3002;&#x8981;&#x6D4B;&#x8BD5;&#x8F6F;&#x4EF6;&#x5305;&#xFF0C;&#x8BF7;&#x5728;<code>test</code>&#x76EE;&#x5F55;&#x4E2D;&#x6DFB;&#x52A0;<a href="https://flutter.io/testing/#unit-testing" target="_blank">unit tests</a>&#x3002;&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x770B;&#x770B;&#x5982;&#x4F55;&#x7EC4;&#x7EC7;Package&#x5305;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x6211;&#x4EEC;&#x4EE5;shelf Package&#x4E3A;&#x4F8B;&#xFF0C;&#x5B83;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/docs/imgs/shelf-02e5fd43b660fcef7dbe6a883c40159e0379c8ee2088288ca60ed7dc8781bafd.png" alt="shelf root directory contains example, lib, test, and tool subdirectories"></p>
<p>&#x5728;lib&#x6839;&#x76EE;&#x5F55;&#x4E0B;&#x7684;shelf.dart&#x4E2D;&#xFF0C;&#x5BFC;&#x51FA;&#x4E86;&#x591A;&#x4E2A;lib/src&#x76EE;&#x5F55;&#x4E0B;&#x7684;dart&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">export</span> <span class="token string">&apos;src/cascade.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/handler.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/handlers/logger.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/hijack_exception.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/middleware.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/pipeline.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/request.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/response.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/server.dart&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">export</span> <span class="token string">&apos;src/server_handler.dart&apos;</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x800C;Package&#x4E2D;&#x4E3B;&#x8981;&#x7684;&#x529F;&#x80FD;&#x7684;&#x6E90;&#x7801;&#x90FD;&#x5728;src&#x76EE;&#x5F55;&#x4E0B;&#x3002;shelf Package&#x4E5F;&#x5BFC;&#x51FA;&#x4E86;&#x4E00;&#x4E2A;&#x8FF7;&#x4F60;&#x5E93;: shelf_io&#xFF0C;&#x5B83;&#x4E3B;&#x8981;&#x662F;&#x5904;&#x7406;HttpRequest&#x7684;&#x3002;</p>
<p><strong>&#x5BFC;&#x5165;&#x5305;</strong></p>
<p>&#x5F53;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;Package&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&quot;package:&quot;&#x6307;&#x4EE4;&#x6765;&#x6307;&#x5B9A;&#x5305;&#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">import</span> <span class="token string">&apos;package:utilities/utilities.dart&apos;</span><span class="token punctuation">;</span>
</code></pre>
<p>&#x540C;&#x4E00;&#x4E2A;&#x5305;&#x4E2D;&#x7684;&#x6E90;&#x7801;&#x6587;&#x4EF6;&#x4E4B;&#x95F4;&#x4E5F;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x76F8;&#x5BF9;&#x8DEF;&#x5F84;&#x6765;&#x5BFC;&#x5165;&#x3002;</p>
<h3 id="&#x751F;&#x6210;&#x6587;&#x6863;">&#x751F;&#x6210;&#x6587;&#x6863;</h3>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <a href="https://github.com/dart-lang/dartdoc#dartdoc" target="_blank">dartdoc</a> &#x5DE5;&#x5177;&#x6765;&#x4E3A;Package&#x751F;&#x6210;&#x6587;&#x6863;&#xFF0C;&#x5F00;&#x53D1;&#x8005;&#x9700;&#x8981;&#x505A;&#x7684;&#x5C31;&#x662F;&#x9075;&#x5B88;&#x6587;&#x6863;&#x6CE8;&#x91CA;&#x8BED;&#x6CD5;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x6587;&#x6863;&#x6CE8;&#x91CA;&#xFF0C;&#x6700;&#x540E;&#x4F7F;&#x7528;dartdoc&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x751F;&#x6210;API&#x6587;&#x6863;&#xFF08;&#x4E00;&#x4E2A;&#x9759;&#x6001;&#x7F51;&#x7AD9;&#xFF09;&#x3002;&#x6587;&#x6863;&#x6CE8;&#x91CA;&#x662F;&#x4F7F;&#x7528;&#x4E09;&#x659C;&#x7EBF;&quot;///&quot;&#x5F00;&#x59CB;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token comment">/// The event handler responsible for updating the badge in the UI.</span>
<span class="token keyword">void</span> <span class="token function">updateBadge</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8BE6;&#x7EC6;&#x7684;&#x6587;&#x6863;&#x8BED;&#x6CD5;&#x8BF7;&#x53C2;&#x8003;<a href="https://github.com/dart-lang/dartdoc#dartdoc" target="_blank">dartdoc</a> &#x3002;</p>
<h3 id="&#x5904;&#x7406;&#x5305;&#x7684;&#x76F8;&#x4E92;&#x4F9D;&#x8D56;">&#x5904;&#x7406;&#x5305;&#x7684;&#x76F8;&#x4E92;&#x4F9D;&#x8D56;</h3>
<p>&#x5982;&#x679C;&#x6211;&#x4EEC;&#x6B63;&#x5728;&#x5F00;&#x53D1;&#x4E00;&#x4E2A;<code>hello</code>&#x5305;&#xFF0C;&#x5B83;&#x4F9D;&#x8D56;&#x4E8E;&#x53E6;&#x4E00;&#x4E2A;&#x5305;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x5C06;&#x8BE5;&#x4F9D;&#x8D56;&#x5305;&#x6DFB;&#x52A0;&#x5230;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x7684;<code>dependencies</code>&#x90E8;&#x5206;&#x3002; &#x4E0B;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x4F7F;<code>url_launcher</code>&#x63D2;&#x4EF6;&#x7684;API&#x5728;<code>hello</code>&#x5305;&#x4E2D;&#x662F;&#x53EF;&#x7528;&#x7684;&#xFF1A;</p>
<p>&#x5728; <code>hello/pubspec.yaml</code>&#x4E2D;:</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">dependencies</span><span class="token punctuation">:</span>
  <span class="token key atrule">url_launcher</span><span class="token punctuation">:</span> ^0.4.2
</code></pre>
<p>&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x5728;<code>hello</code>&#x4E2D;<code>import &apos;package:url_launcher/url_launcher.dart&apos;</code> &#x7136;&#x540E;&#x8C03;&#x7528; <code>launch()</code>&#x65B9;&#x6CD5;&#x4E86;&#x3002;</p>
<p>&#x8FD9;&#x4E0E;&#x5728;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6216;&#x4EFB;&#x4F55;&#x5176;&#x4ED6;Dart&#x9879;&#x76EE;&#x4E2D;&#x5F15;&#x7528;&#x8F6F;&#x4EF6;&#x5305;&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x4E0D;&#x540C;&#x3002;</p>
<p>&#x4F46;&#x662F;&#xFF0C;&#x5982;&#x679C;<code>hello</code>&#x78B0;&#x5DE7;&#x662F;&#x4E00;&#x4E2A;&#x63D2;&#x4EF6;&#x5305;&#xFF0C;&#x5176;&#x5E73;&#x53F0;&#x7279;&#x5B9A;&#x7684;&#x4EE3;&#x7801;&#x9700;&#x8981;&#x8BBF;&#x95EE;<code>url_launcher</code>&#x516C;&#x5F00;&#x7684;&#x7279;&#x5B9A;&#x4E8E;&#x5E73;&#x53F0;&#x7684;API&#xFF0C;&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x8FD8;&#x9700;&#x8981;&#x4E3A;&#x7279;&#x5B9A;&#x4E8E;&#x5E73;&#x53F0;&#x7684;&#x6784;&#x5EFA;&#x6587;&#x4EF6;&#x6DFB;&#x52A0;&#x5408;&#x9002;&#x7684;&#x4F9D;&#x8D56;&#x58F0;&#x660E;&#xFF0C;&#x5982;&#x4E0B;&#x6240;&#x793A;&#x3002;</p>
<p><strong>Android</strong></p>
<p>&#x5728; <code>hello/android/build.gradle</code>:</p>
<pre class="language-"><code class="lang-groovy">android <span class="token punctuation">{</span>
    <span class="token comment">// lines skipped</span>
    dependencies <span class="token punctuation">{</span>
        provided rootProject<span class="token operator">.</span><span class="token function">findProject</span><span class="token punctuation">(</span><span class="token string">&quot;:url_launcher&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x60A8;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x5728;<code>hello/android/src</code>&#x6E90;&#x7801;&#x4E2D;<code>import io.flutter.plugins.urllauncher.UrlLauncherPlugin</code>&#x8BBF;&#x95EE;<code>UrlLauncherPlugin</code>&#x7C7B;&#x3002;</p>
<p><strong>iOS</strong></p>
<p>&#x5728;<code>hello/ios/hello.podspec</code>:</p>
<pre class="language-"><code class="lang-ruby"><span class="token constant">Pod</span><span class="token punctuation">:</span><span class="token punctuation">:</span><span class="token constant">Spec</span><span class="token punctuation">.</span><span class="token keyword">new</span> <span class="token class-name">do</span> <span class="token operator">|</span>s<span class="token operator">|</span>
  <span class="token comment"># lines skipped</span>
  s<span class="token punctuation">.</span>dependency <span class="token string">&apos;url_launcher&apos;</span>
</code></pre>
<p>&#x60A8;&#x73B0;&#x5728;&#x53EF;&#x4EE5;&#x5728;<code>hello/ios/Classes</code>&#x6E90;&#x7801;&#x4E2D; <code>#import &quot;UrlLauncherPlugin.h&quot;</code> &#x7136;&#x540E;&#x8BBF;&#x95EE; <code>UrlLauncherPlugin</code>&#x7C7B;&#x3002;</p>
<h3 id="&#x89E3;&#x51B3;&#x4F9D;&#x8D56;&#x51B2;&#x7A81;">&#x89E3;&#x51B3;&#x4F9D;&#x8D56;&#x51B2;&#x7A81;</h3>
<p>&#x5047;&#x8BBE;&#x6211;&#x4EEC;&#x60F3;&#x5728;&#x6211;&#x4EEC;&#x7684;<code>hello</code>&#x5305;&#x4E2D;&#x4F7F;&#x7528;<code>some_package</code>&#x548C;<code>other_package</code>&#xFF0C;&#x5E76;&#x4E14;&#x8FD9;&#x4E24;&#x4E2A;&#x5305;&#x90FD;&#x4F9D;&#x8D56;<code>url_launcher</code>&#xFF0C;&#x4F46;&#x662F;&#x4F9D;&#x8D56;&#x7684;&#x662F;<code>url_launcher</code>&#x7684;&#x4E0D;&#x540C;&#x7684;&#x7248;&#x672C;&#x3002; &#x90A3;&#x6211;&#x4EEC;&#x5C31;&#x6709;&#x6F5C;&#x5728;&#x7684;&#x51B2;&#x7A81;&#x3002;&#x907F;&#x514D;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x7684;&#x6700;&#x597D;&#x65B9;&#x6CD5;&#x662F;&#x5728;&#x6307;&#x5B9A;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x65F6;&#xFF0C;&#x7A0B;&#x5E8F;&#x5305;&#x4F5C;&#x8005;&#x4F7F;&#x7528;<a href="https://www.dartlang.org/tools/pub/dependencies#version-constraints" target="_blank">&#x7248;&#x672C;&#x8303;&#x56F4;</a>&#x800C;&#x4E0D;&#x662F;&#x7279;&#x5B9A;&#x7248;&#x672C;&#x3002;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">dependencies</span><span class="token punctuation">:</span>
  <span class="token key atrule">url_launcher</span><span class="token punctuation">:</span> ^0.4.2    <span class="token comment"># &#x8FD9;&#x6837;&#x4F1A;&#x8F83;&#x597D;, &#x4EFB;&#x4F55;0.4.x(x &gt;= 2)&#x90FD;&#x53EF;.</span>
  <span class="token key atrule">image_picker</span><span class="token punctuation">:</span> &apos;0.1.1&apos;   <span class="token comment"># &#x4E0D;&#x662F;&#x5F88;&#x597D;&#xFF0C;&#x53EA;&#x6709;0.1.1&#x7248;&#x672C;.</span>
</code></pre>
<p>&#x5982;&#x679C;<code>some_package</code>&#x58F0;&#x660E;&#x4E86;&#x4E0A;&#x9762;&#x7684;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;,<code>other_package</code>&#x58F0;&#x660E;&#x4E86;<code>url_launcher</code>&#x7248;&#x672C;&#x50CF;&#x2019;0.4.5&#x2019;&#x6216;&#x2019;^0.4.0&#x2019;&#xFF0C;pub&#x5C06;&#x80FD;&#x591F;&#x81EA;&#x52A8;&#x89E3;&#x51B3;&#x95EE;&#x9898;&#x3002; </p>
<p>&#x5373;&#x4F7F;<code>some_package</code>&#x548C;<code>other_package</code>&#x58F0;&#x660E;&#x4E86;&#x4E0D;&#x517C;&#x5BB9;&#x7684;<code>url_launcher</code>&#x7248;&#x672C;&#xFF0C;&#x5B83;&#x4ECD;&#x7136;&#x53EF;&#x80FD;&#x4F1A;&#x548C;<code>url_launcher</code>&#x4EE5;&#x517C;&#x5BB9;&#x7684;&#x65B9;&#x5F0F;&#x6B63;&#x5E38;&#x5DE5;&#x4F5C;&#x3002; &#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5411;<code>hello</code>&#x5305;&#x7684;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;&#x6027;&#x8986;&#x76D6;&#x58F0;&#x660E;&#x6765;&#x5904;&#x7406;&#x51B2;&#x7A81;&#xFF0C;&#x4ECE;&#x800C;&#x5F3A;&#x5236;&#x4F7F;&#x7528;&#x7279;&#x5B9A;&#x7248;&#x672C;&#xFF1A;</p>
<p>&#x5F3A;&#x5236;&#x4F7F;&#x7528; <code>0.4.3</code>&#x7248;&#x672C;&#x7684;<code>url_launcher</code>&#xFF0C;&#x5728; <code>hello/pubspec.yaml</code>&#x4E2D;:</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">dependencies</span><span class="token punctuation">:</span>
  <span class="token key atrule">some_package</span><span class="token punctuation">:</span>
  <span class="token key atrule">other_package</span><span class="token punctuation">:</span>
<span class="token key atrule">dependency_overrides</span><span class="token punctuation">:</span>
  <span class="token key atrule">url_launcher</span><span class="token punctuation">:</span> <span class="token string">&apos;0.4.3&apos;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x51B2;&#x7A81;&#x7684;&#x4F9D;&#x8D56;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x5305;&#xFF0C;&#x800C;&#x662F;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x4E8E;Android&#x7684;&#x5E93;&#xFF0C;&#x6BD4;&#x5982;<code>guava</code>&#xFF0C;&#x90A3;&#x4E48;&#x5FC5;&#x987B;&#x5C06;&#x4F9D;&#x8D56;&#x91CD;&#x5199;&#x58F0;&#x660E;&#x6DFB;&#x52A0;&#x5230;Gradle&#x6784;&#x5EFA;&#x903B;&#x8F91;&#x4E2D;&#x3002;</p>
<p>&#x5F3A;&#x5236;&#x4F7F;&#x7528;<code>23.0</code>&#x7248;&#x672C;&#x7684;<code>guava</code>&#x5E93;&#xFF0C;&#x5728;<code>hello/android/build.gradle</code>&#x4E2D;&#xFF1A;</p>
<pre class="language-"><code class="lang-groovy">configurations<span class="token operator">.</span>all <span class="token punctuation">{</span>
    resolutionStrategy <span class="token punctuation">{</span>
        force <span class="token string">&apos;com.google.guava:guava:23.0-android&apos;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>Cocoapods&#x76EE;&#x524D;&#x4E0D;&#x63D0;&#x4F9B;&#x4F9D;&#x8D56;&#x8986;&#x76D6;&#x529F;&#x80FD;&#x3002;</p>
<h3 id="&#x53D1;&#x5E03;package">&#x53D1;&#x5E03;Package</h3>
<p>&#x4E00;&#x65E6;&#x5B9E;&#x73B0;&#x4E86;&#x4E00;&#x4E2A;&#x5305;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;<a href="https://pub.dartlang.org/" target="_blank">Pub</a>&#x4E0A;&#x53D1;&#x5E03;&#x5B83; &#xFF0C;&#x8FD9;&#x6837;&#x5176;&#x4ED6;&#x5F00;&#x53D1;&#x8005;&#x5C31;&#x53EF;&#x4EE5;&#x8F7B;&#x677E;&#x4F7F;&#x7528;&#x5B83;&#x3002;</p>
<p>&#x5728;&#x53D1;&#x5E03;&#x4E4B;&#x524D;&#xFF0C;&#x68C0;&#x67E5;<code>pubspec.yaml</code>&#x3001;<code>README.md</code>&#x4EE5;&#x53CA;<code>CHANGELOG.md</code>&#x6587;&#x4EF6;&#xFF0C;&#x4EE5;&#x786E;&#x4FDD;&#x5176;&#x5185;&#x5BB9;&#x7684;&#x5B8C;&#x6574;&#x6027;&#x548C;&#x6B63;&#x786E;&#x6027;&#x3002;&#x7136;&#x540E;&#xFF0C;&#x8FD0;&#x884C; dry-run &#x547D;&#x4EE4;&#x4EE5;&#x67E5;&#x770B;&#x662F;&#x5426;&#x90FD;&#x51C6;&#x5907;OK&#x4E86;:</p>
<pre class="language-"><code class="lang-shell">flutter packages pub publish --dry-run
</code></pre>
<p>&#x9A8C;&#x8BC1;&#x65E0;&#x8BEF;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x8FD0;&#x884C;&#x53D1;&#x5E03;&#x547D;&#x4EE4;&#x4E86;&#xFF1A;</p>
<pre class="language-"><code class="lang-shell">flutter packages pub publish
</code></pre>
<blockquote>
<p>&#x5982;&#x679C;&#x4F60;&#x9047;&#x5230;&#x5305;&#x53D1;&#x5E03;&#x5931;&#x8D25;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x5148;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x56E0;&#x4E3A;&#x4F17;&#x6240;&#x5468;&#x77E5;&#x7684;&#x7F51;&#x7EDC;&#x539F;&#x56E0;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x7F51;&#x7EDC;&#x95EE;&#x9898;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;VPN&#xFF0C;&#x8FD9;&#x91CC;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x4E00;&#x4E9B;&#x4EE3;&#x7406;&#x53EA;&#x4F1A;&#x4EE3;&#x7406;&#x90E8;&#x5206;APP&#x7684;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#xFF0C;&#x5982;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#xFF0C;&#x5B83;&#x4EEC;&#x53EF;&#x80FD;&#x5E76;&#x4E0D;&#x80FD;&#x4EE3;&#x7406;dart&#x7684;&#x7F51;&#x7EDC;&#x8BF7;&#x6C42;&#xFF0C;&#x6240;&#x4EE5;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5373;&#x4F7F;&#x5F00;&#x4E86;&#x4EE3;&#x7406;&#x4E5F;&#x4F9D;&#x7136;&#x65E0;&#x6CD5;&#x8FDE;&#x63A5;&#x5230;Pub&#xFF0C;&#x56E0;&#x6B64;&#xFF0C;&#x5728;&#x53D1;&#x5E03;Pub&#x5305;&#x65F6;&#x4F7F;&#x7528;&#x5168;&#x5C40;&#x4EE3;&#x7406;&#x6216;&#x5168;&#x5C40;VPN&#x4F1A;&#x4FDD;&#x9669;&#x4E9B;&#x3002;&#x5982;&#x679C;&#x7F51;&#x7EDC;&#x6CA1;&#x6709;&#x95EE;&#x9898;&#xFF0C;&#x4EE5;&#x7BA1;&#x7406;&#x5458;&#x6743;&#x9650;(sudo)&#x8FD0;&#x884C;&#x53D1;&#x5E03;&#x547D;&#x4EE4;&#x91CD;&#x8BD5;&#x3002;</p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 包与插件">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="platform-channel.html" class="navigation navigation-next " aria-label="Next page: 插件开发：平台通道简介">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"开发package","level":"1.13.1","depth":2,"next":{"title":"插件开发：平台通道简介","level":"1.13.2","depth":2,"path":"chapter11/platform-channel.md","ref":"chapter11/platform-channel.md","articles":[]},"previous":{"title":"包与插件","level":"1.13","depth":1,"path":"chapter11/index.md","ref":"chapter11/index.md","articles":[{"title":"开发package","level":"1.13.1","depth":2,"path":"chapter11/develop_package.md","ref":"chapter11/develop_package.md","articles":[]},{"title":"插件开发：平台通道简介","level":"1.13.2","depth":2,"path":"chapter11/platform-channel.md","ref":"chapter11/platform-channel.md","articles":[]},{"title":"插件开发：实现Android端API","level":"1.13.3","depth":2,"path":"chapter11/android_implement.md","ref":"chapter11/android_implement.md","articles":[]},{"title":"插件开发：实现IOS端API","level":"1.13.4","depth":2,"path":"chapter11/ios_implement.md","ref":"chapter11/ios_implement.md","articles":[]},{"title":"系统能力调用","level":"1.13.5","depth":2,"path":"todo.md","ref":"todo.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","toggle-chapters","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0.3/docs/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"wendux 824783146@qq.com","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter11/develop_package.md","mtime":"2018-12-09T13:12:23.228Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-14T10:32:57.346Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/theme.js"></script>
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script>
    var _hmt = _hmt || [];
    $("#bd").remove();
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?170231fea4f81697eb046edc1a91fe5b";
        var s = document.getElementsByTagName("script")[0];
        hm.id = "bd"
        s.parentNode.insertBefore(hm, s);
    })();

    function init() {
        var p = location.pathname;
        _hmt.push(['_trackPageview', p]);
        if (p[p.length - 1] === '/') {
            p += "index.md"
        } else {
            p = p.split(".")[0] + ".md";
        }
        p = "https://github.com/flutterchina/flutter-in-action/blob/master/docs" + p;
        $(".pull-right .fa-edit").parent("a").attr("href", p);
        $("table").wrap("<div style='overflow: auto'></div>");
        //百度统计
        var e = /([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi, r = window.location.href,
            t = document.referrer;
        if (!e.test(r)) {
            var o = "https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif";
            t ? (o += "?r=" + encodeURIComponent(document.referrer), r && (o += "&l=" + r)) : r && (o += "?l=" + r);
            var i = new Image;
            i.src = o
        }
        $(".copyright").remove();
        $("<div class='copyright'> 本书仍在勘误阶段，请勿以任何形式私自传播，作者保留对本书的版权。</div>").appendTo(".page-inner");
    }

    function hookAPI(api, ob, fn) {
        return function () {
            var result = api.apply(ob, [].slice.call(arguments));

            setTimeout(fn, 1000);
            return result;
        }
    }

    function addAD() {
        if (location.href !== 'https://book.flutterchina.club/' && $("#book-search-results .ad").length == 0) {
            var id=Math.ceil(Math.random()*10)%2;
            $(".ad"+id).clone().hide().fadeIn().prependTo("#book-search-results")
            setTimeout(function () {
                $(".body-inner").animate({scrollTop: 0}, 200)
            }, 800);
        }
    }

    function _track(p,url) {
        _hmt.push(['_trackEvent', 'ad', 'click', p]);
        setTimeout(function () {
            location.href = url
        }, 100);
    }

    // setInterval(addAD, 300);

    init();


    if (history.pushState) {
        history.pushState = hookAPI(history.pushState, history, init);
    }

</script>
</body>

</html>

